package com.sys.tool;

import cn.edu.ctgu.ghl.fetion.Fetion;

/**
 * Created by IntelliJ IDEA.
 * User: mabo
 * Date: 2010-1-14
 * Time: 13:28:09
 * To change this template use File | Settings | File Templates.
 */
public class FetionTool {

    private static Fetion f = new Fetion("13911552167", "56789mb");


    /**
     * 发送飞信消息
     * @param phone 电话号码
     * @param sms 消息内容
     */
    public static void sendSms(String phone, String sms) {
        FetionTool.isLogined();
        f.sendSms("tel:"+phone, sms);
    }

     public static void sendSmsByUri(String phone, String sms) {
        FetionTool.isLogined();
        f.sendSms(phone, sms);
    }


    /**
     * 添加飞信联系人
     * @param phone 电话号码
     * @param sms 验证信息
     */
    public static void addBuddy(String phone, String sms) {
        FetionTool.isLogined();
        f.addBuddy(phone, sms);
        f.updateContacts();
    }


    /**
     * 检查是否登录，若没有登录，则登录，并设置隐身
     */
    private static void isLogined() {
        if (!f.isLogined()) {
            f = new Fetion("13911552167", "56789mb");
            f.login();
            f.setPresence("0");
        }
    }

    /**
     * 登出飞信
     */
    public static void logout() {
        if(f.isLogined()){
            f.logout();
        }
    }

    public static void main(String[] args) {
        FetionTool.sendSmsByUri("tel:13911552167","试试");
    }
}
